package com.hockeo.client.ui.base.tree;

import java.util.List;

import com.extjs.gxt.ui.client.data.BeanModel;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype;

/**
 * Tree configuration.
 *
 * @version $Id$
 * @author jjanke
 */
public interface IVHTreeConfig
{
  /**
   * Invoked by the tree when it needs to load the root nodes.
   *
   * @param callback the callback to use for asynchronous RPC calls
   */
  public void loadRoots( AsyncCallback<List<?>> callback );

  /**
   * Invoked by the tree when it requires to load the child nodes of a given parent node.
   *
   * @param parent the parent node for which the child nodes are requested
   * @param callback the callback to use for asynchronous RPC calls
   */
  public void loadChildNodes( BeanModel parent, AsyncCallback<List<?>> callback );

  /**
   * Indicates whether the given tree node has any children that should be displayed in
   * the tree or not.
   *
   * @param model the model representing the tree node for which is is required to know if
   *          it has child nodes or not
   * @return <code>true</code> if the given node has children, <code>false</code>
   *         otherwise
   */
  public boolean hasChildren( BeanModel model );

  /**
   * Returns the icon to be used by the given tree node.
   *
   * @param model the model for which an icon is requested
   * @return the icon to use for the given model or <code>null</code> to render the node
   *         without specific icon
   */
  public AbstractImagePrototype getIcon( BeanModel model );

  /**
   * Returns the label that should be used when the given node is displayed in the tree.
   *
   * @param model the model for which to return a label
   * @return the node's label, it is guaranteed to be a non <code>null</code> value
   */
  public String getLabel( BeanModel model );
}
